package com.ls.springbootdemo.controller;

import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author: 挥之以墨
 * @Date: 2021/10/7 19:46
 */
@Controller
@RequestMapping("/redisson")
public class RedissonController {


    @Autowired
    private RedissonClient redissonClient;


    @GetMapping("/lock")
    public void lock(String key) {
        RLock lock = redissonClient.getLock(key);
        lock.lock();

        lock.unlock();
    }
}
